package com.atguigu.controller;

import com.atguigu.constant.MqConst;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SimulateQuartzController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    //发送上架秒杀商品的通知  模拟定时任务
    @GetMapping("/sendMsgToScanSeckill")
    public String sendMsgToScanSeckill(){
        //通过mq发消息给shop_seckill微服务
        rabbitTemplate.convertAndSend(MqConst.SCAN_SECKILL_EXCHANGE,MqConst.SCAN_SECKILL_ROUTE_KEY,"");
        return "success";
    }
    //模拟秒杀结束 下架秒杀的商品
    @GetMapping("/sendMsgToClearRedis")
    public String sendMsgToClearRedis(){
        rabbitTemplate.convertAndSend(MqConst.CLEAR_REDIS_EXCHANGE,  MqConst.CLEAR_REDIS_ROUTE_KEY, "");
        return "success";
    }

}
